package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TMusicInfo;
import com.ruoyi.system.service.ITMusicInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 音乐列Controller
 * 
 * @author ruoyi
 * @date 2025-09-24
 */
@RestController
@RequestMapping("/system/info")
public class TMusicInfoController extends BaseController
{
    @Autowired
    private ITMusicInfoService tMusicInfoService;

    /**
     * 查询音乐列列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMusicInfo tMusicInfo)
    {
        startPage();
        List<TMusicInfo> list = tMusicInfoService.selectTMusicInfoList(tMusicInfo);
        return getDataTable(list);
    }

    /**
     * 导出音乐列列表
     */
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "音乐列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TMusicInfo tMusicInfo)
    {
        List<TMusicInfo> list = tMusicInfoService.selectTMusicInfoList(tMusicInfo);
        ExcelUtil<TMusicInfo> util = new ExcelUtil<TMusicInfo>(TMusicInfo.class);
        util.exportExcel(response, list, "音乐列数据");
    }

    /**
     * 获取音乐列详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{musicId}")
    public AjaxResult getInfo(@PathVariable("musicId") Long musicId)
    {
        return success(tMusicInfoService.selectTMusicInfoByMusicId(musicId));
    }

    /**
     * 新增音乐列
     */
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "音乐列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMusicInfo tMusicInfo)
    {
        return toAjax(tMusicInfoService.insertTMusicInfo(tMusicInfo));
    }

    /**
     * 修改音乐列
     */
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "音乐列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMusicInfo tMusicInfo)
    {
        return toAjax(tMusicInfoService.updateTMusicInfo(tMusicInfo));
    }

    /**
     * 删除音乐列
     */
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "音乐列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{musicIds}")
    public AjaxResult remove(@PathVariable Long[] musicIds)
    {
        return toAjax(tMusicInfoService.deleteTMusicInfoByMusicIds(musicIds));
    }
}
